package day5;

import java.util.Arrays;
import java.util.Random;

/**
 * @author oldliu
 * @since 1.0
 */
public class RandomTest {
    public static void main(String[] args) {
        System.out.println(Math.random());//[0-1)
        Random r=new Random();
        System.out.println("随机整数：");
        for(int i=1;i<=20;i++){
            //包含正负！
            System.out.print(r.nextInt()+" ");
        }
        System.out.println();
        System.out.println("随机浮点数：");
        for(int i=1;i<=20;i++){
            //包含正负！
            System.out.print(r.nextDouble()+" ");
        }
        System.out.println();
        System.out.println("随机boolean：");
        for(int i=1;i<=20;i++){
            //包含正负！
            System.out.print(r.nextBoolean()+" ");
        }
        System.out.println();
        System.out.println("限制范围的整数[0-200)：");
        for(int i=1;i<=20;i++){
            //包含正负！
            System.out.print(r.nextInt(200)+" ");
        }
        System.out.println();
        System.out.println("随机byte数组：");
        byte b[]=new byte[12];
        for(int i=1;i<=20;i++){

            r.nextBytes(b);
            System.out.println(Arrays.toString(b)+" ");
        }
        System.out.println();
    }
}
